import React, { useEffect } from 'react';

export default function FED4() {
    function namespace(oNamespace, sPackage) {
        let arr = sPackage.split('.');
        let o = oNamespace;
        for (let i = 0; i < arr.length; i++) {
            let key = arr[i]
            if (typeof o[key] != 'object') {
                o[key] = {};
            }
            console.log(o)
            o = o[key];
        }

        console.log(o, oNamespace)
        // return res;

        // let list = sPackage.split('.');
        // let tmp = oNamespace;
        // for (var k in list) {
        //     if (typeof tmp[list[k]] !== 'object') {
        //         tmp[list[k]] = {};
        //     }
        //     tmp = tmp[list[k]];
        // }
        // return oNamespace;
    }
    useEffect(() => {
        namespace({ a: { test: 1, b: 2 } }, 'a.b.c.d')
    }, [])
    return (
        <div>1</div>
    )
}